package SmartControl_Mediator_22;

import SmartControl_Mediator_22.Equipment.*;

public class SmartMediatorImpl implements SmartMediator {
    private final CoffeeMachine coffeeMachine;
    private final Curtain curtain;
    private final Light light;

    public SmartMediatorImpl(CoffeeMachine coffeeMachine, Curtain curtain, Light light) {
        this.coffeeMachine = coffeeMachine;
        this.curtain = curtain;
        this.light = light;
    }

    @Override
    public void notify(Device sender, String event) {
        if(sender instanceof Alarm) {
            if(event.equals("Alarm is ON")) {
                System.out.println("闹钟响了，打开所有设备");
                coffeeMachine.on();
                curtain.on();
                light.on();
            } else if (event.equals("Alarm is OFF")) {
                System.out.println("闹钟停了，关闭所有设备");
                coffeeMachine.off();
                curtain.off();
                light.off();
            }
        }
    }
}
